package com.example.community;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Set;

@RunWith(SpringRunner.class)
@SpringBootTest
@ContextConfiguration(classes = CommunityApplication.class)
public class testRedisZset {
    @Autowired
    private RedisTemplate redisTemplate;
    @Test
    public void testInter(){
        String key1 = "followee:111:3";
        String key2 = "followee:101:3";
        String key3 = "result";
         redisTemplate.opsForZSet().intersectAndStore(key1,key2,key3);
         Set<Integer> ids = redisTemplate.opsForZSet().reverseRange(key3,0,10);
         for (Integer id : ids){
             System.out.println(id);
         }
    }
}
